package com.ruoyi.contract.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.contract.domain.PaymentCollectionPlan;
import com.ruoyi.contract.service.IPaymentCollectionPlanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收付款计划Controller
 * 
 * @author ruoyi
 * @date 2024-10-18
 */
@RestController
@RequestMapping("/contract/PaymentCollectionPlan")
public class PaymentCollectionPlanController extends BaseController
{
    @Autowired
    private IPaymentCollectionPlanService paymentCollectionPlanService;

    /**
     * 查询收付款计划列表
     */
    @PreAuthorize("@ss.hasPermi('contract:PaymentCollectionPlan:list')")
    @GetMapping("/list")
    public TableDataInfo list(PaymentCollectionPlan paymentCollectionPlan)
    {
        startPage();
        List<PaymentCollectionPlan> list = paymentCollectionPlanService.selectPaymentCollectionPlanList(paymentCollectionPlan);
        return getDataTable(list);
    }

    /**
     * 导出收付款计划列表
     */
    @PreAuthorize("@ss.hasPermi('contract:PaymentCollectionPlan:export')")
    @Log(title = "收付款计划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaymentCollectionPlan paymentCollectionPlan)
    {
        List<PaymentCollectionPlan> list = paymentCollectionPlanService.selectPaymentCollectionPlanList(paymentCollectionPlan);
        ExcelUtil<PaymentCollectionPlan> util = new ExcelUtil<PaymentCollectionPlan>(PaymentCollectionPlan.class);
        util.exportExcel(response, list, "收付款计划数据");
    }

    /**
     * 获取收付款计划详细信息
     */
    @PreAuthorize("@ss.hasPermi('contract:PaymentCollectionPlan:query')")
    @GetMapping(value = "/{paymentCollectionPlanId}")
    public AjaxResult getInfo(@PathVariable("paymentCollectionPlanId") Long paymentCollectionPlanId)
    {
        return success(paymentCollectionPlanService.selectPaymentCollectionPlanByPaymentCollectionPlanId(paymentCollectionPlanId));
    }

    /**
     * 新增收付款计划
     */
    @PreAuthorize("@ss.hasPermi('contract:PaymentCollectionPlan:add')")
    @Log(title = "收付款计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaymentCollectionPlan paymentCollectionPlan)
    {
        return toAjax(paymentCollectionPlanService.insertPaymentCollectionPlan(paymentCollectionPlan));
    }

    /**
     * 修改收付款计划
     */
    @PreAuthorize("@ss.hasPermi('contract:PaymentCollectionPlan:edit')")
    @Log(title = "收付款计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaymentCollectionPlan paymentCollectionPlan)
    {
        return toAjax(paymentCollectionPlanService.updatePaymentCollectionPlan(paymentCollectionPlan));
    }

    /**
     * 删除收付款计划
     */
    @PreAuthorize("@ss.hasPermi('contract:PaymentCollectionPlan:remove')")
    @Log(title = "收付款计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paymentCollectionPlanIds}")
    public AjaxResult remove(@PathVariable Long[] paymentCollectionPlanIds)
    {
        return toAjax(paymentCollectionPlanService.deletePaymentCollectionPlanByPaymentCollectionPlanIds(paymentCollectionPlanIds));
    }
}
